<template>
  <div class="index">
    <el-container>
      <el-aside width="260px">
        <header>
          <div class="left">
            <span class="iconfont icon-qiandaizi"></span>
            <span class="title">考勤管理</span>
          </div>
          <div class="right">
            <span class="iconfont icon-gengduo"></span>
            <span class="iconfont icon-icadd2"></span>
          </div>
        </header>
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          router >
          <el-menu-item index="/index/business" v-if="showmenu(11)">
            <i class="el-icon-set-up"></i>
            <span slot="title">出差申请</span>
          </el-menu-item>

          <el-menu-item index="/index/outside" v-if="showmenu(12)">
            <i class="el-icon-set-up"></i>
            <span slot="title">外勤打卡</span>
          </el-menu-item>

          <el-menu-item index="/index/leave" v-if="showmenu(13)">
            <i class="el-icon-set-up"></i>
            <span slot="title">请假申请</span>
          </el-menu-item>

          <el-menu-item index="/index/work" v-if="showmenu(14)">
            <i class="el-icon-set-up"></i>
            <span slot="title">加班申请</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <!-- 二级路由组件渲染出口 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {

  computed:{
    ...mapState(['userinfo'])
  },
  methods:{
    showmenu(permissions){
      let index=this.userinfo.role.permissions.indexOf(permissions)
      if(index!=-1){
        return true;
      }else{
        return false;
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.index{
  height: 100%;
  header{
    height: 60px;
    padding: 0 20px;
    border-right: solid 1px #e6e6e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left{
      .title{
      font-size: 18px;
      font-weight: 700;
      margin-left: 10px;
    }
    .icon-qiandaizi{
      font-size: 18px;
      color: #fff4d9;
      background-color: #ffb100;
    }
    }
    .right{
       .iconfont{
        font-size: 18px;
       }
      .icon-icadd2{
        margin-left: 10px;
        color: #fb9234;
      }
    }
  }
}
.el-container{
  height: 100%;
}
.el-main{
  height: 100%;
  background-color: #f9fafc;
  padding: 0;
}
.el-menu{
  .is-active{
    color:#fb933f;
    background-color:#fcebdc;	
  }
}
</style>